<?php
namespace voxfa\net\core;

class NetworkInterfaceSupport {
	
	private $support;
	
	public function __construct(){
		
	}
	
	public function save(NetworkInterface $interface){
		if($this->exist($interface->getName()))
			$this->support->updateInterface($interface);
		else 
			$this->support->insertInterface($interface);
	}
	
	public function remove($interfaceName){
		if($this->exist($interfaceName))
			return $this->support->deleteInterface($interfaceName);
		throw new InterfaceNotExisted($interfaceName);
	}
	
	public function exist($interfaceName){
		return $this->support->existInterface($interfaceName);
	}
	
	public function getByName($interfaceName){
		return $this->support->selectByName($interfaceName);
	}
	
	public function getNetworkInterfaces(){
		return $this->support->selectAll();
	}
}